home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 4777 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.3 KB

  1. Path: qualcomm.com!usenet
  2. From: nabbasi@qualcomm.com (Nasser Abbasi)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Possible VC 4.0 bug?
  5. Date: 1 Feb 1996 01:06:49 GMT
  6. Organization: QUALCOMM
  7. Message-ID: <4ep3n9$a31@qualcomm.com>
  8. References: <4eor3o$d06@enterprise.turningpoint.com>
  9. NNTP-Posting-Host: nabbasi.qualcomm.com
  10. Mime-Version: 1.0
  11. X-Newsreader: WinVN 0.93.14
  12.  
  13. In article <4eor3o$d06@enterprise.turningpoint.com>, sathan@cybercom.net 
  14. says...
  15. >
  16. >When I compile and run the following code under MSVC 4.0, I get an 
  17. access 
  18. >violation on the delete:
  19. >
  20. >------------------------------------------------------------------------
  21. -
  22. >
  23. >#include <stdio.h>
  24. >
  25. >class foo
  26. >        {
  27. >        public :
  28. >                virtual ~foo( );
  29. >        };
  30. >
  31. >foo::~foo( )
  32. >        {
  33. >        printf( "In foo::~foo.\n" );
  34. >        }
  35. >
  36. >int main( )
  37. >        {
  38. >        foo* p = new foo[ 0 ];
  39. >
  40. >        delete [] p;
  41. >
  42. >        return 0;
  43. >        }
  44. >
  45. >------------------------------------------------------------------------
  46. --
  47. >
  48. >Everything works fine, and the destructor is never called, if the 
  49. destructor 
  50. >is not virtual.
  51. >
  52. >Is this a problem with VC, or with my understanding of how a new of size 
  53. zero 
  54. >should work? Thanks.
  55. >
  56.  
  57.  
  58. Did the above actually compile? you are trying to allocate array of size 
  59. zero? that should not work outside a class members ?
  60.  
  61. Nasser
  62.  
  63.  
  64.